import java.util.Scanner;

public class Main {
    private static Movie[] movies = {
            new Movie(1, "肖申克的救赎", "剧情", 9.7, "弗兰克·德拉邦特", "希望让人自由"),
            new Movie(2, "阿甘正传", "剧情", 9.5, "罗伯特·泽米吉斯", "生活就像一盒巧克力"),
            new Movie(3, "泰坦尼克号", "爱情", 9.4, "詹姆斯·卡梅隆", "永不沉没的爱情"),
            new Movie(4, "这个杀手不太冷", "动作", 9.4, "吕克·贝松", "怪蜀黍和小萝莉的故事"),
            new Movie(5, "盗梦空间", "科幻", 9.3, "克里斯托弗·诺兰", "梦境与现实")
    };

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        System.out.println("案例 面向对象综合案例-模仿电影信息浏览系统");

        while(true) {
            System.out.println("\n1、查询全部电影信息");
            System.out.println("2、根据电影ID查询电影详情");
            System.out.print("请选择您要操作的功能：");

            String choice = sc.next();

            switch(choice) {
                case "1":
                    showAllMovies();
                    break;
                case "2":
                    System.out.print("请输入电影ID：");
                    int id = sc.nextInt();
                    searchMovieById(id);
                    break;
                default:
                    System.out.println("输入有误，请重新选择！");
            }
        }
    }

    // 显示全部电影简略信息
    private static void showAllMovies() {
        System.out.println("\n---全部电影信息---");
        for (Movie movie : movies) {
            System.out.println("ID：" + movie.getId() +
                    " | 名称：" + movie.getName() +
                    " | 类型：" + movie.getType() +
                    " | 评分：" + movie.getScore());
        }
    }

    // 根据ID查询电影详情
    private static void searchMovieById(int id) {
        for (Movie movie : movies) {
            if (movie.getId() == id) {
                System.out.println("\n---电影详情---");
                System.out.println("ID：" + movie.getId());
                System.out.println("名称：" + movie.getName());
                System.out.println("类型：" + movie.getType());
                System.out.println("评分：" + movie.getScore());
                System.out.println("导演：" + movie.getDirector());
                System.out.println("简介：" + movie.getInfo());
                return;
            }
        }
        System.out.println("未找到ID为" + id + "的电影！");
    }
}
